package com.iris.live.services.data.repositories.impl;

import com.iris.live.services.common.reconsitution.CollectionUtils;
import com.iris.live.services.data.models.CustomCarConfigureModel;
import com.iris.live.services.data.repositories.ICustomCarConfigureRepository;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/3/22.
 */

@Repository
public class CustomCarConfigureRepositoryImpl extends BaseRepository implements ICustomCarConfigureRepository {

    @Override
    public  List<Map> findByStoreId(String storeId, Integer status,String permit){
        String  sql = "SELECT \n" +
                        "configure.id as id, \n"+
                        "configure.custom_name as customName, \n"+
                        "configure.store_id as storeId, \n"+
                        "configure.permit as permit, \n"+
                        "configure.total_price as totalPrice, \n"+
                        "configure.fact_price as factPrice, \n"+
                        "configure.status as status, \n"+
                        "configure.last_msrp as lastMsrp, \n"+
                        "configure.created_time as createdTime \n"+
                    "FROM \n"+
                        "custom_car_configure as configure \n"+
                    "WHERE \n"+
                        "configure.store_id IN "+
                        " (:ids)"+
                    " AND \n"+
                        "configure.permit =:permit \n";

        Map<String, Object> params = new HashMap<>();
        params.put("permit", permit);
        params.put("ids", CollectionUtils.getStr4SQLINParam(CollectionUtils.ArrToCollection(storeId.split(CollectionUtils.SPLIT_STR_STRING))));
        return  this.getList(sql.toString(), params) ;
    }

}
